package com.boot.controller;

import com.boot.entity.Time;
import com.boot.repository.TimeRepository;
import com.boot.vo.BaseMessage;
import com.boot.vo.MessageHandler;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@CrossOrigin(origins = "*")

@RequestMapping("/time")
public class TimeController {
    @Autowired
    TimeRepository timeRepository;

    @RequestMapping("setTime")
    @ResponseBody
    public BaseMessage<?> setTime(Time time){
        timeRepository.save(time);
        return MessageHandler.createSuccessVo("修改成功！");
    }

    @GetMapping("TimeList")
    public List<Time> timeList(){
        return timeRepository.findAll();
    }

}
